package com.qfedu.tantu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qfedu.tantu.dao.AttractionsDao;
import com.qfedu.tantu.entity.Attractions;
import com.qfedu.tantu.service.intf.AttractionsService;
import com.qfedu.tantu.vo.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * .=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-.
 * |                     ______                     |
 * |                  .-"      "-.                  |
 * |                 /            \                 |
 * |     _          |              |          _     |
 * |    ( \         |,  .-.  .-.  ,|         / )    |
 * |     > "=._     | )(__/  \__)( |     _.=" <     |
 * |    (_/"=._"=._ |/     /\     \| _.="_.="\_)    |
 * |           "=._"(_     ^^     _)"_.="           |
 * |               "=\__|IIIIII|__/="               |
 * |              _.="| \IIIIII/ |"=._              |
 * |    _     _.="_.="\          /"=._"=._     _    |
 * |   ( \_.="_.="     `--------`     "=._"=._/ )   |
 * |    > _.="                            "=._ <    |
 * |   (_/                                    \_)   |
 * |                                                |
 * '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
 * -----------------代码的搬运工-----------------
 *
 * @Date: 2022/07/01/18:34
 */
@Service
public class AttractionsServiceImpl implements AttractionsService {
    @Resource
    private AttractionsDao dao;
    @Override
    public R selectBycity(Attractions attractions) {
        if(attractions!=null){
            if(attractions.getNeedday()!=null) {
                System.out.println(attractions.getNeedday());
                QueryWrapper<Attractions> queryWrapper = new QueryWrapper<>();
                queryWrapper.eq("city", attractions.getCity());
                queryWrapper.le("needday", attractions.getNeedday());
                return R.ok(dao.selectList(queryWrapper));
            }else{
                QueryWrapper<Attractions> queryWrapper1 = new QueryWrapper<>();
                queryWrapper1.eq("city",attractions.getCity());
                return R.ok(dao.selectList(queryWrapper1));
            }
        }

        return R.fail("请输入有效的城市名");
    }

    @Override
    public R indexQuery() {
        return R.ok(dao.indexQuery());
    }

    @Override
    public R selectByid(int id) {
       if(id>0){

           return R.ok(dao.selectById(id));
       }
        return R.fail();
    }
}
